"""
Tracert超时统计
1、用多线程同时统计10次
2、查看统计超时数（500ms）【】
"""

import os, time, threading


def nowTime():
    a = time.strftime("%Y-%m-%d %H:%M:%S")
    return "[" + a + "] "


def sys_Tracert_1(ip, n):
    print(f"Begin 1-{n}")
    os.system(f"echo {nowTime()}     >>  ./tracert/1.txt")
    os.system(f"tracert -w 500 -d {ip} >> ./tracert/1.txt")


def sys_Tracert_2(ip):
    for x in range(10):
        os.system(f"echo {nowTime()}\n >>  ./tracert/2.txt")
        os.system(f"tracert -w 500 -d {ip} >> ./tracert/2.txt")


if __name__ == "__main__":
    time.localtime()
    IP = r"10.226.10.21"
    for i in range(10):
        sys_Tracert_1(IP, i)

    other = threading.Thread(target=sys_Tracert_2, args=(IP, ))
    other.start()
